# dataGenSubs.pm - perl modules for dataGen.pl

package dataGenSubs;

#print a welcome message
sub welcomeMessage {
	my $timeStamp = localtime;
	print STDOUT "\nINFO:\t ---------------------------------";
	print STDOUT "\nINFO:\t -  TIME SERIES DATA GEN SCRIPT  -";
	print STDOUT "\nINFO:\t ---------------------------------\n";
	print STDOUT "INFO:\t -  $timeStamp     -";
	print STDOUT "\nINFO:\t ---------------------------------\n";
	print STDOUT "INFO:\t\n";
}

#check if there are the correct number of command line arguments
sub checkNumCmdArgs {

	# if there are not exactly one command line arg.
	# ( note number of command line args = $#ARGV+1 )
	if ( $#ARGV != 0 ) {
		print $#ARGV;
		my $helpfile = "dataGenHelp.pl";
		if ( -e $helpfile ) {
			system("perl $helpfile | more");
			exit;
		}
		else {
			die "\nERROR:\thelp file '$helpfile' not present !!\n\n";
		}
	}
}

sub checkParamFileType {
	my $tseriesTYPE = substr $ARGV[0], -6;
	if ( $tseriesTYPE !~ /^.param$/s ) {
		print STDOUT "=OUT:\n=OUT:\t===ERROR===\n";
		print STDOUT "=OUT:\tTime series paramter file ( $ARGV[0] ) \n";
		print STDOUT "=OUT:\tNeeds to be of type '.param'.\n";
		print STDOUT "=OUT:\n=OUT:\n";
		exit(9);
	}
	else {}
}


## subroutine to sort a list of numbers
sub by_number {
    if    ( $a < $b ) { -1 }
    elsif ( $a > $b ) { 1 }
    else              { 0 }
}





1;                                          # need to end with a true value
